package com.blog.controller.active;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.blog.common.base.BaseController;
import com.blog.common.base.ResponseReslut;
import com.blog.common.util.pic.PicUtils;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Controller
@RequestMapping("/upload")
public class UploadPicController extends BaseController {
 
	 		
    @ResponseBody
    @RequestMapping(value = "/picUpload",method = RequestMethod.POST)
    public ResponseReslut picUpload(MultipartFile file,HttpServletRequest request)
    {
    	//判断用户是否登陆  
    	Map<String,Object> map=PicUtils.Pic(file, request);
    	boolean fg=(boolean) map.get("state");
    	String msg=(String) map.get("msg");
    	if(fg)
    	{
    		String picName=(String) map.get("picName");
    		return setResultSuccess(msg,picName);
    	}

    	return setResultSuccess(msg);
    }
    
}
